<%--
  Created by IntelliJ IDEA.
  User: 你忙吧t233
  Date: 2021/10/20
  Time: 9:56
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<style>
    body{
        background-color: cornsilk;
    }
    .biaoge{
        position: absolute;
        left: 35%;
        top: 10%;
    }
</style>
<form action="insert">
    <div class="biaoge">
        <table border="1">
            <tr>
                <td colspan="3">新增联系人</td></tr>
            <tr>
                <td>姓名</td>
                <Td colspan="2"><input type="text" name="A_Name"></Td>
            </tr>
            <tr>
                <td>电话</td>
                <Td colspan="2"><input type="text" name="A_Phone"></Td>
            </tr>
            <tr>
                <td>邮箱</td>
                <Td><input type="text" name="A_Mail" id="email"></Td>
                <td><input type="button" onclick="a()" value="验证"></td>
            </tr>
            <tr>
                <td>关系</td>
                <td colspan="2"><select name="A_Relation">
                    <option>请选择关系类型</option>
                    <option>家人</option>
                    <option>同事</option>
                    <option>朋友</option>
                    <option>同学</option>
                    <option>其他</option>
                </select></td>
            </tr>
            <tr>
                <td colspan="3"><input type="submit" value="增加联系人"></td></tr>
        </table>
    </div>

</form>
</body>
</html>
<script>
    function a() {
        var email = document.getElementById("email").value;
        var reg = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/;
        if(reg.test(email)){
            alert("邮箱格式正确");
        }else{
            alert("邮箱格式不正确");
        }
    };

    var arr = document.getElementsByTagName("tr");
    for(var i=0;i<arr.length;i++){
        if (i%2==0){
            arr[i].style.backgroundColor="yellow";
        }
    }

</script>
